package alo;

import java.util.List;

/**
 * @ClassName T
 * @Description TODO
 * @Author Fanxc
 * @DATE 2021/4/28 14:46
 * @Version 1.0
 */
public class T {
    class ListNode{
        int val;
        ListNode next;
        ListNode(int val){
            this.val=val;
        }
    }
    public ListNode remove(ListNode head,int n){
        if (head==null||n<=0)return head;
        ListNode dummp=new  ListNode(0);
        dummp.next=head;
        ListNode fast=head;
        ListNode slow=dummp;
        for (int i = 0; i < n; i++) {
            fast=fast.next;
            if (fast==null)return null;
        }
        while (fast!=null){
            fast=fast.next;
            slow=slow.next;
        }
        fast=slow.next.next;
        slow.next=fast;
        return dummp.next;
    }
}
